package com.asd.netty.Servcie.Imp;

import com.asd.netty.netty.common.InformationRepository;
import com.asd.netty.Servcie.InformationService;
import com.asd.netty.entity.Information;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;

import java.lang.reflect.Field;
import java.util.List;

@Slf4j
@Service("information")
public class InformationServiceImp implements InformationService{

    Information information = new Information();
    Field[] field = information.getClass().getDeclaredFields();

    @Autowired
    private InformationRepository repository;

    /**
     * 查询所有信息
     */
    @Override
    public List<Information> findInformation() {
        return this.repository.findAll();
    }

    /**
     * 添加信息
     */
    @Override
    public void addInformation(Information information) {
        information.getTheme();
        information.getLength();
        information.getData();
        this.repository.save(information);
    }

    /**
     * 分页显示
     * @param pageable
     * @return
     */
    @Override
    public Page<Information> finfAll(Pageable pageable) {
        return this.repository.findAll(pageable);
    }
}
